package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue;

/**
 *
 * (首页模块)TB_IndexModule
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_IndexModule#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_indexModule")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("首页模块")
@com.lianjing.sh.processing.info.annotation.InfoComment("首页模块")
public class TB_IndexModule
 extends TBSuper_BaseIDAndTimeAndOrderValue
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	com.sh_lianjing.state.HasStatable,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 类型 */
		public bairui.international.model.type.Type_IndexModule getType();
		/** 名称 */
		public String getName();
		/** 状态 */
		public com.lianjing.sh.model.uml.model.status.State_UpDown getState();
		/** 置顶标志 */
		public Boolean getTopFlag();
		/** 分页标志 */
		public Boolean getPageFlag();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_IndexModule properties(MustProperties properties) {
		this.setType(properties.getType());
		this.setName(properties.getName());
		this.setState(properties.getState());
		this.setTopFlag(properties.getTopFlag());
		this.setPageFlag(properties.getPageFlag());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_IndexModule(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 说明 */
		public String getComment();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_IndexModule properties(OptionalSingleProperties properties) {
		this.setComment(properties.getComment());
		return this;
	}
	
	
	
	public TB_IndexModule(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 类型 */
		public bairui.international.model.type.Type_IndexModule getType();
		/** 名称 */
		public String getName();
		/** 状态 */
		public com.lianjing.sh.model.uml.model.status.State_UpDown getState();
		/** 置顶标志 */
		public Boolean getTopFlag();
		/** 分页标志 */
		public Boolean getPageFlag();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_IndexModule properties(CurrentMustProperties properties) {
		this.setType(properties.getType());
		this.setName(properties.getName());
		this.setState(properties.getState());
		this.setTopFlag(properties.getTopFlag());
		this.setPageFlag(properties.getPageFlag());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
		/** 说明 */
		public String getComment();
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_IndexModule properties(CurrentOptionalSingleProperties properties) {
		this.setComment(properties.getComment());
		return this;
	}
	
	public TB_IndexModule(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_IndexModule(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean
	) {
		update(bean);
	}
	
	public TB_IndexModule update(com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_IndexModule.this);
			if(isOverride_getOrderValue){
				TB_IndexModule.this.setOrderValue(orderValue);
			}
	
			java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleImg> indexModuleImgs = getIndexModuleImgs(TB_IndexModule.this);
			if(isOverride_getIndexModuleImgs){
				TB_IndexModule.this.setIndexModuleImgs(indexModuleImgs);
			}
	
			bairui.international.model.type.Type_IndexModule type = getType(TB_IndexModule.this);
			if(isOverride_getType){
				TB_IndexModule.this.setType(type);
			}
	
			String name = getName(TB_IndexModule.this);
			if(isOverride_getName){
				TB_IndexModule.this.setName(name);
			}
	
			String comment = getComment(TB_IndexModule.this);
			if(isOverride_getComment){
				TB_IndexModule.this.setComment(comment);
			}
	
			com.lianjing.sh.model.uml.model.status.State_UpDown state = getState(TB_IndexModule.this);
			if(isOverride_getState){
				TB_IndexModule.this.setState(state);
			}
	
			java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleProduct> indexModuleProducts = getIndexModuleProducts(TB_IndexModule.this);
			if(isOverride_getIndexModuleProducts){
				TB_IndexModule.this.setIndexModuleProducts(indexModuleProducts);
			}
	
			Boolean topFlag = getTopFlag(TB_IndexModule.this);
			if(isOverride_getTopFlag){
				TB_IndexModule.this.setTopFlag(topFlag);
			}
	
			Boolean pageFlag = getPageFlag(TB_IndexModule.this);
			if(isOverride_getPageFlag){
				TB_IndexModule.this.setPageFlag(pageFlag);
			}
		}
	
		public TB_IndexModule up(){
			return TB_IndexModule.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_IndexModule it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 首页模块图片视频 */
		private boolean isOverride_getIndexModuleImgs = true;
		public java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleImg> getIndexModuleImgs(TB_IndexModule it) throws Exception { 
			isOverride_getIndexModuleImgs = false; 
			return null;
		}
		/** 类型 */
		private boolean isOverride_getType = true;
		public bairui.international.model.type.Type_IndexModule getType(TB_IndexModule it) throws Exception { 
			isOverride_getType = false; 
			return null;
		}
		/** 名称 */
		private boolean isOverride_getName = true;
		public String getName(TB_IndexModule it) throws Exception { 
			isOverride_getName = false; 
			return null;
		}
		/** 说明 */
		private boolean isOverride_getComment = true;
		public String getComment(TB_IndexModule it) throws Exception { 
			isOverride_getComment = false; 
			return null;
		}
		/** 状态 */
		private boolean isOverride_getState = true;
		public com.lianjing.sh.model.uml.model.status.State_UpDown getState(TB_IndexModule it) throws Exception { 
			isOverride_getState = false; 
			return null;
		}
		/** 首页模块产品 */
		private boolean isOverride_getIndexModuleProducts = true;
		public java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleProduct> getIndexModuleProducts(TB_IndexModule it) throws Exception { 
			isOverride_getIndexModuleProducts = false; 
			return null;
		}
		/** 置顶标志 */
		private boolean isOverride_getTopFlag = true;
		public Boolean getTopFlag(TB_IndexModule it) throws Exception { 
			isOverride_getTopFlag = false; 
			return null;
		}
		/** 分页标志 */
		private boolean isOverride_getPageFlag = true;
		public Boolean getPageFlag(TB_IndexModule it) throws Exception { 
			isOverride_getPageFlag = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_IndexModule() {
	}
	
	public TB_IndexModule(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_IndexModule(
		@lombok.NonNull TB_IndexModule bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setCreator(bean.getCreator());
		this.setLastModifier(bean.getLastModifier());
		this.setIndexModuleImgs(bean.getIndexModuleImgs());
		this.setType(bean.getType());
		this.setName(bean.getName());
		this.setComment(bean.getComment());
		this.setState(bean.getState());
		this.setIndexModuleProducts(bean.getIndexModuleProducts());
		this.setTopFlag(bean.getTopFlag());
		this.setPageFlag(bean.getPageFlag());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("创建者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("创建者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="creator_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin creator;

	@com.lianjing.sh.model.common.annotation.Comment("最后修改者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("最后修改者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="lastModifier_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin lastModifier;

	@com.lianjing.sh.model.common.annotation.Comment("首页模块图片视频")
	@com.lianjing.sh.processing.info.annotation.InfoComment("首页模块图片视频")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.OneToMany(cascade={javax.persistence.CascadeType.ALL}, mappedBy="indexModule")
	private java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleImg> indexModuleImgs;

	@com.lianjing.sh.model.common.annotation.Comment("类型")
	@com.lianjing.sh.processing.info.annotation.InfoComment("类型")
	@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
	@javax.persistence.Column(name="type", nullable=false)
	private bairui.international.model.type.Type_IndexModule type;

	@com.lianjing.sh.model.common.annotation.Comment("名称")
	@com.lianjing.sh.processing.info.annotation.InfoComment("名称")
	@javax.persistence.Column(name="name", nullable=false, length=50)
	private String name;

	@com.lianjing.sh.model.common.annotation.Comment("说明")
	@com.lianjing.sh.processing.info.annotation.InfoComment("说明")
	@javax.persistence.Column(name="comment", length=255)
	private String comment;

	@com.lianjing.sh.model.common.annotation.Comment("状态")
	@com.lianjing.sh.processing.info.annotation.InfoComment("状态")
	@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
	@javax.persistence.Column(name="state", nullable=false)
	private com.lianjing.sh.model.uml.model.status.State_UpDown state;

	@com.lianjing.sh.model.common.annotation.Comment("首页模块产品")
	@com.lianjing.sh.processing.info.annotation.InfoComment("首页模块产品")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.OneToMany(cascade={javax.persistence.CascadeType.ALL}, mappedBy="indexModule")
	private java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleProduct> indexModuleProducts;

	@com.lianjing.sh.model.common.annotation.Comment("置顶标志")
	@com.lianjing.sh.processing.info.annotation.InfoComment("置顶标志")
	@javax.persistence.Column(name="topFlag", nullable=false)
	private Boolean topFlag;

	@com.lianjing.sh.model.common.annotation.Comment("分页标志")
	@com.lianjing.sh.processing.info.annotation.InfoComment("分页标志")
	@javax.persistence.Column(name="pageFlag", nullable=false)
	private Boolean pageFlag;

	/** get[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin getCreator() {
		return this.creator;
	}

	/** get[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin getLastModifier() {
		return this.lastModifier;
	}

	/** get[首页模块图片视频] */
	public java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleImg> getIndexModuleImgs() {
		return this.indexModuleImgs;
	}

	/** get[类型] */
	public bairui.international.model.type.Type_IndexModule getType() {
		return this.type;
	}

	/** get[名称] */
	public String getName() {
		return this.name;
	}

	/** get[说明] */
	public String getComment() {
		return this.comment;
	}

	/** get[状态] */
	public com.lianjing.sh.model.uml.model.status.State_UpDown getState() {
		return this.state;
	}

	/** get[首页模块产品] */
	public java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleProduct> getIndexModuleProducts() {
		return this.indexModuleProducts;
	}

	/** get[置顶标志] */
	public Boolean getTopFlag() {
		return this.topFlag;
	}

	/** get[分页标志] */
	public Boolean getPageFlag() {
		return this.pageFlag;
	}

	/** set[创建者] */
	public void setCreator(bairui.international.model.domain.jpa.TB_Admin creator) {
		this.creator = creator;
	}

	/** set[最后修改者] */
	public void setLastModifier(bairui.international.model.domain.jpa.TB_Admin lastModifier) {
		this.lastModifier = lastModifier;
	}

	/** set[首页模块图片视频] */
	public void setIndexModuleImgs(java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleImg> indexModuleImgs) {
		this.indexModuleImgs = indexModuleImgs;
	}

	/** set[类型] */
	public void setType(bairui.international.model.type.Type_IndexModule type) {
		this.type = type;
	}

	/** set[名称] */
	public void setName(String name) {
		this.name = name;
	}

	/** set[说明] */
	public void setComment(String comment) {
		this.comment = comment;
	}

	/** set[状态] */
	public void setState(com.lianjing.sh.model.uml.model.status.State_UpDown state) {
		this.state = state;
	}

	/** set[首页模块产品] */
	public void setIndexModuleProducts(java.util.List<bairui.international.model.domain.jpa.TB_IndexModuleProduct> indexModuleProducts) {
		this.indexModuleProducts = indexModuleProducts;
	}

	/** set[置顶标志] */
	public void setTopFlag(Boolean topFlag) {
		this.topFlag = topFlag;
	}

	/** set[分页标志] */
	public void setPageFlag(Boolean pageFlag) {
		this.pageFlag = pageFlag;
	}





	/** add[IndexModuleImgs] */
	public TB_IndexModule addIndexModuleImgs(bairui.international.model.domain.jpa.TB_IndexModuleImg ... indexModuleImgs){
		if(this.indexModuleImgs == null){
			this.indexModuleImgs = new java.util.ArrayList<>();
		}
		for(bairui.international.model.domain.jpa.TB_IndexModuleImg bean : indexModuleImgs){
			bean.setIndexModule(this);
			this.indexModuleImgs.add(bean);
		}
		return this;
	}
	/** add[IndexModuleProducts] */
	public TB_IndexModule addIndexModuleProducts(bairui.international.model.domain.jpa.TB_IndexModuleProduct ... indexModuleProducts){
		if(this.indexModuleProducts == null){
			this.indexModuleProducts = new java.util.ArrayList<>();
		}
		for(bairui.international.model.domain.jpa.TB_IndexModuleProduct bean : indexModuleProducts){
			bean.setIndexModule(this);
			this.indexModuleProducts.add(bean);
		}
		return this;
	}
	
	/** remove[IndexModuleImgs] */
	public TB_IndexModule removeIndexModuleImgs(bairui.international.model.domain.jpa.TB_IndexModuleImg ... indexModuleImgs){
		if(this.indexModuleImgs == null){
			return this;
		}
		for(bairui.international.model.domain.jpa.TB_IndexModuleImg bean : indexModuleImgs){
			bean.setIndexModule(null);
			this.indexModuleImgs.remove(bean);
		}
		return this;
	}
	/** remove[IndexModuleProducts] */
	public TB_IndexModule removeIndexModuleProducts(bairui.international.model.domain.jpa.TB_IndexModuleProduct ... indexModuleProducts){
		if(this.indexModuleProducts == null){
			return this;
		}
		for(bairui.international.model.domain.jpa.TB_IndexModuleProduct bean : indexModuleProducts){
			bean.setIndexModule(null);
			this.indexModuleProducts.remove(bean);
		}
		return this;
	}
	
	/**
	 * contains[IndexModuleImgs]
	 *
	 * 全部输入都包含：返回 true
	 * 输入中有至少有一个不包含：返回 false
	 */
	public boolean containsIndexModuleImgs(bairui.international.model.domain.jpa.TB_IndexModuleImg ... indexModuleImgs){
		if(this.indexModuleImgs == null || indexModuleImgs==null || indexModuleImgs.length<=0){
			return false;
		}
		return this.indexModuleImgs.containsAll(java.util.Arrays.asList(indexModuleImgs));
	}
	/**
	 * contains[IndexModuleProducts]
	 *
	 * 全部输入都包含：返回 true
	 * 输入中有至少有一个不包含：返回 false
	 */
	public boolean containsIndexModuleProducts(bairui.international.model.domain.jpa.TB_IndexModuleProduct ... indexModuleProducts){
		if(this.indexModuleProducts == null || indexModuleProducts==null || indexModuleProducts.length<=0){
			return false;
		}
		return this.indexModuleProducts.containsAll(java.util.Arrays.asList(indexModuleProducts));
	}
	

	/** take[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin takeCreator(){
		if(null == this.creator){
			this.creator = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.creator;
	}
	
	/** take[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin takeLastModifier(){
		if(null == this.lastModifier){
			this.lastModifier = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.lastModifier;
	}
	
	/** must[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin mustCreator() {
		return this.creator;
	}
	
	/** must[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin mustLastModifier() {
		return this.lastModifier;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_IndexModule other = (TB_IndexModule) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		String name = this.getName();
		if(null != name){
			return String.valueOf(name);
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
		this.setCreator((bairui.international.model.domain.jpa.TB_Admin)user);
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setModifyTime(new java.util.Date());
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}

	/**
	 * 状态相关
	 */
	public com.lianjing.sh.model.uml.model.status.State_UpDown state(){
		return this.getState();
	}


}
